﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Craps
{
    public class GameObject
    {
        private Vector2 mScale;

        public Vector2 center;
        public Texture2D sprite;
        public float rotation;
        public Vector2 velocity;
        public bool alive;
        
        public bool visible;
        

        public Vector2 origin;

        public GameObject(Texture2D loadedTexture)
        {
            sprite = loadedTexture;
            origin = new Vector2(sprite.Width / 2, sprite.Height / 2);
            rotation = 0.0f;
            center = origin;
            velocity = Vector2.Zero;
            alive = false;
            visible = true;
            scale = Vector2.One;
        }

        public GameObject(GameObject copy)
        {
            sprite = copy.sprite;
            center = copy.center;
            rotation = copy.rotation;
            velocity = copy.velocity;
            alive = copy.alive;
            visible = copy.visible;
            scale = copy.mScale;
            origin = copy.origin;
        }

        public Vector2 scale
        {
            get
            {
                return mScale;
            }
            set
            {
                mScale = value;
            }
        }
        public Vector2 topleft
        {
            get
            {
                return new Vector2(center.X - (sprite.Width / 2 * scale.X),
                    center.Y - (sprite.Height / 2 * scale.Y));
            }
        }
        public Rectangle rectangle
        {
            get
            {
                return new Rectangle((int)topleft.X, (int)topleft.Y, (int)(sprite.Width * scale.X),
                    (int)(sprite.Height * scale.Y));
            }
        }
    }
}
